import {
  getAllData
} from '@/api/system/role'

const state = () => ({
  rolelist: [] // 角色列表
})

const getters = {
  rolelist: state => state.rolelist
}

const mutations = {
  // 设置角色数据
  SET_ROLE_LIST (state, data) {
    state.rolelist = data
  }
}

const actions = {
  // 请求角色列表
  async getAllRoleList ({ commit }) {
    const res = await getAllData()
    commit('SET_ROLE_LIST', res)
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
